﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace CustomControls.ImageButton.ImageInfiniteControl
{
    public partial class ImageInfiniteControl : UserControl
    {
        public ImageInfiniteControl()
        {
            InitializeComponent();
            this.button.Click += Button_Click;
        }

        /// <summary>
        /// 点击时
        /// </summary>
        public event EventHandler Click;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (IsToDoSelect)
            {
                this.Click?.Invoke(this, new EventArgs());
            }
        }

        #region NormalImageUri

        /// <summary>
        /// 获取或设置默认图片Uri
        /// </summary>
        public ImageSource NormalImageUri
        {
            get { return (ImageSource)GetValue(NormalImageUriProperty); }
            set { SetValue(NormalImageUriProperty, value); }
        }

        public static readonly DependencyProperty NormalImageUriProperty =
            DependencyProperty.Register("NormalImageUri", typeof(ImageSource), typeof(ImageInfiniteControl), new PropertyMetadata(null));

        #endregion

        #region DisableImageUri

        /// <summary>
        /// 获取或设置按钮不可用时的图片Uri
        /// </summary>
        public ImageSource DisableImageUri
        {
            get { return (ImageSource)GetValue(DisableImageUriProperty); }
            set { SetValue(DisableImageUriProperty, value); }
        }

        public static readonly DependencyProperty DisableImageUriProperty =
            DependencyProperty.Register("DisableImageUri", typeof(ImageSource), typeof(ImageInfiniteControl), new PropertyMetadata(null));

        #endregion

        #region DownImageUri

        /// <summary>
        /// 获取或设置按键按下时的图片Uri
        /// </summary>
        public ImageSource DownImageUri
        {
            get { return (ImageSource)GetValue(DownImageUriProperty); }
            set { SetValue(DownImageUriProperty, value); }
        }

        public static readonly DependencyProperty DownImageUriProperty =
            DependencyProperty.Register("DownImageUri", typeof(ImageSource), typeof(ImageInfiniteControl), new PropertyMetadata(null));

        #endregion

        #region OverImageUri

        /// <summary>
        /// 获取或设置鼠标越过时的图片Uri
        /// </summary>
        public ImageSource OverImageUri
        {
            get { return (ImageSource)GetValue(OverImageUriProperty); }
            set { SetValue(OverImageUriProperty, value); }
        }

        public static readonly DependencyProperty OverImageUriProperty =
            DependencyProperty.Register("OverImageUri", typeof(ImageSource), typeof(ImageInfiniteControl), new PropertyMetadata(null));


        #endregion

        #region IsToDoSelect

        /// <summary>
        /// 获取或设置鼠标越过时的图片Uri
        /// </summary>
        public bool IsToDoSelect
        {
            get { return (bool)GetValue(IsToDoSelectProperty); }
            set { SetValue(IsToDoSelectProperty, value); }
        }

        public static readonly DependencyProperty IsToDoSelectProperty =
            DependencyProperty.Register("IsToDoSelect", typeof(bool), typeof(ImageInfiniteControl), new PropertyMetadata(true));


        #endregion

        #region IsBtSelected
        /// <summary>
        /// 按钮是否被选中
        /// </summary>
        public bool IsBtSelected
        {
            get { return (bool)GetValue(IsBtSelectedProperty); }
            set { SetValue(IsBtSelectedProperty, value); }
        }
        public static readonly DependencyProperty IsBtSelectedProperty =
            DependencyProperty.Register("IsBtSelected", typeof(bool), typeof(ImageInfiniteControl), new PropertyMetadata(false));
        #endregion

        #region DisplayText

        /// <summary>
        /// 获取或设置显示的文本
        /// </summary>
        public string DisplayText
        {
            get { return (string)GetValue(DisplayTextProperty); }
            set { SetValue(DisplayTextProperty, value); }
        }

        public static readonly DependencyProperty DisplayTextProperty =
            DependencyProperty.Register("DisplayText", typeof(string), typeof(ImageInfiniteControl), new PropertyMetadata(null));

        #endregion

        #region TextFontSize
        /// 文本字体大小
        /// </summary>
        public int TextFontSize
        {
            get { return (int)GetValue(TextFontSizeProperty); }
            set { SetValue(TextFontSizeProperty, value); }
        }
        public static readonly DependencyProperty TextFontSizeProperty =
    DependencyProperty.Register("TextFontSize", typeof(int), typeof(ImageInfiniteControl), new PropertyMetadata(12));
        #endregion

        #region TextMargin
        /// <summary>
        /// 文本位置
        /// </summary>
        public string TextMargin
        {
            get { return (string)GetValue(TextMarginProperty); }
            set { SetValue(TextMarginProperty, value); }
        }
        public static readonly DependencyProperty TextMarginProperty =
      DependencyProperty.Register("TextMargin", typeof(string), typeof(ImageInfiniteControl), new PropertyMetadata("0"));
        #endregion


        #region Orientationd
        public Orientation Orientationd
        {
            get { return (Orientation)GetValue(OrientationdProperty); }
            set { SetValue(OrientationdProperty, value); }
        }
        public static readonly DependencyProperty OrientationdProperty =
            DependencyProperty.RegisterAttached("Orientationd", typeof(Orientation), typeof(ImageInfiniteControl), new PropertyMetadata(Orientation.Vertical));
        #endregion

        #region ImageWidth
        public int ImageWidth
        {
            get { return (int)GetValue(ImageWidthProperty); }
            set { SetValue(ImageWidthProperty, value); }
        }
        public static readonly DependencyProperty ImageWidthProperty =
            DependencyProperty.RegisterAttached("ImageWidth", typeof(int), typeof(ImageInfiniteControl), new PropertyMetadata(8));
        #endregion
        #region ImageWidth
        public int ImageHeight
        {
            get { return (int)GetValue(ImageHeightProperty); }
            set { SetValue(ImageHeightProperty, value); }
        }
        public static readonly DependencyProperty ImageHeightProperty =
            DependencyProperty.RegisterAttached("ImageHeight", typeof(int), typeof(ImageInfiniteControl), new PropertyMetadata(8));
        #endregion

        #region BorderPadding
        public string BorderPadding
        {
            get { return (string)GetValue(BorderPaddingProperty); }
            set { SetValue(BorderPaddingProperty, value); }
        }
        public static readonly DependencyProperty BorderPaddingProperty =
            DependencyProperty.RegisterAttached("BorderPadding", typeof(string), typeof(ImageInfiniteControl), new PropertyMetadata("5"));
        #endregion

        #region BorderWidth
        public int BorderWidth
        {
            get { return (int)GetValue(BorderWidthProperty); }
            set { SetValue(BorderWidthProperty, value); }
        }
        public static readonly DependencyProperty BorderWidthProperty =
            DependencyProperty.RegisterAttached("BorderWidth", typeof(int), typeof(ImageInfiniteControl), new PropertyMetadata(50));
        #endregion

        #region BorderHeight
        public int BorderHeight
        {
            get { return (int)GetValue(BorderHeightProperty); }
            set { SetValue(BorderHeightProperty, value); }
        }
        public static readonly DependencyProperty BorderHeightProperty =
            DependencyProperty.RegisterAttached("BorderHeight", typeof(int), typeof(ImageInfiniteControl), new PropertyMetadata(30));
        #endregion

        #region BorderBackgroud
        public SolidColorBrush BorderBackgroud
        {
            get { return (SolidColorBrush)GetValue(BorderBackgroudProperty); }
            set { SetValue(BorderBackgroudProperty, value); }
        }
        public static readonly DependencyProperty BorderBackgroudProperty =
            DependencyProperty.RegisterAttached("BorderBackgroud", typeof(SolidColorBrush), typeof(ImageInfiniteControl), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
        #endregion

        #region BorderBackgroudHov
        public SolidColorBrush BorderBackgroudHov
        {
            get { return (SolidColorBrush)GetValue(BorderBackgroudHovProperty); }
            set { SetValue(BorderBackgroudHovProperty, value); }
        }
        public static readonly DependencyProperty BorderBackgroudHovProperty =
            DependencyProperty.RegisterAttached("BorderBackgroudHov", typeof(SolidColorBrush), typeof(ImageInfiniteControl), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
        #endregion

        #region BorderBackgroudHov
        public SolidColorBrush BorderBackgroudSelect
        {
            get { return (SolidColorBrush)GetValue(BorderBackgroudSelectProperty); }
            set { SetValue(BorderBackgroudSelectProperty, value); }
        }
        public static readonly DependencyProperty BorderBackgroudSelectProperty =
            DependencyProperty.RegisterAttached("BorderBackgroudSelect", typeof(SolidColorBrush), typeof(ImageInfiniteControl), new PropertyMetadata(new SolidColorBrush(Colors.AliceBlue)));
        #endregion

        #region BorderBackgroudDis
        public SolidColorBrush BorderBackgroudDis
        {
            get { return (SolidColorBrush)GetValue(BorderBackgroudDisProperty); }
            set { SetValue(BorderBackgroudDisProperty, value); }
        }
        public static readonly DependencyProperty BorderBackgroudDisProperty =
            DependencyProperty.RegisterAttached("BorderBackgroudDis", typeof(SolidColorBrush), typeof(ImageInfiniteControl), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
        #endregion

        #region BorderCornerRadiusd
        public CornerRadius BorderCornerRadiusd
        {
            get { return (CornerRadius)GetValue(BorderCornerRadiusdProperty); }
            set { SetValue(BorderCornerRadiusdProperty, value); }
        }
        public static readonly DependencyProperty BorderCornerRadiusdProperty =
            DependencyProperty.RegisterAttached("BorderCornerRadiusd", typeof(CornerRadius), typeof(ImageInfiniteControl), new PropertyMetadata(new CornerRadius() { BottomLeft = 5, BottomRight = 5, TopLeft = 5, TopRight = 5 }));
        #endregion

        #region BorderIsPressed
        public SolidColorBrush BorderIsPressed
        {
            get { return (SolidColorBrush)GetValue(BorderIsPressedProperty); }
            set { SetValue(BorderIsPressedProperty, value); }
        }
        public static readonly DependencyProperty BorderIsPressedProperty =
            DependencyProperty.RegisterAttached("BorderIsPressed", typeof(SolidColorBrush), typeof(ImageInfiniteControl), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
        #endregion

        #region BorderThickness
        public Thickness BorderThicknessd
        {
            get { return (Thickness)GetValue(BorderThicknessdProperty); }
            set { SetValue(BorderThicknessdProperty, value); }
        }
        public static readonly DependencyProperty BorderThicknessdProperty =
            DependencyProperty.RegisterAttached("BorderThicknessd", typeof(Thickness), typeof(ImageInfiniteControl), new PropertyMetadata(new Thickness() { Bottom = 0, Left = 0, Right = 0, Top = 0 }));
        #endregion

        #region BorderBrushd
        public SolidColorBrush BorderBrushd
        {
            get { return (SolidColorBrush)GetValue(BorderBrushdProperty); }
            set { SetValue(BorderBrushdProperty, value); }
        }

        public static readonly DependencyProperty BorderBrushdProperty =
            DependencyProperty.RegisterAttached("BorderBrushd", typeof(SolidColorBrush), typeof(ImageInfiniteControl), new PropertyMetadata(new SolidColorBrush(Colors.Transparent)));
        #endregion

        #region ImageMargin
        public string ImageMargin
        {
            get { return (string)GetValue(ImageMarginProperty); }
            set { SetValue(ImageMarginProperty, value); }
        }

        public static readonly DependencyProperty ImageMarginProperty =
            DependencyProperty.RegisterAttached("ImageMargin", typeof(string), typeof(ImageInfiniteControl), new PropertyMetadata("0"));
        #endregion

        #region FontNomalColor
        public SolidColorBrush FontNomalColor
        {
            get { return (SolidColorBrush)GetValue(FontNomalColorProperty); }
            set { SetValue(FontNomalColorProperty, value); }
        }
        public static readonly DependencyProperty FontNomalColorProperty =
          DependencyProperty.Register("FontNomalColor", typeof(SolidColorBrush), typeof(ImageInfiniteControl), new PropertyMetadata(new SolidColorBrush(Colors.Black))); 
        #endregion
    }
}
